//
//  AuthHeaderTableViewCell.m
//  LPTClient
//
//  Created by apple on 2018/12/10.
//  Copyright © 2018 zhaodd. All rights reserved.
//

#import "AuthHeaderTableViewCell.h"

@interface AuthHeaderTableViewCell ()

@property (nonatomic , weak) IBOutlet UIButton *btn1;
@property (nonatomic , weak) IBOutlet UIButton *btn2;
@property (nonatomic , weak) IBOutlet UIButton *btn3;

@property (nonatomic , weak) IBOutlet UILabel *lab1;
@property (nonatomic , weak) IBOutlet UILabel *lab2;
@property (nonatomic , weak) IBOutlet UILabel *lab3;

@end

@implementation AuthHeaderTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];

    self.selectionStyle = UITableViewCellSelectionStyleNone;
    
    [self.btn1 setBackgroundImage:[UIImage imageWithColor:[UIColor colorWithHexString:@"#E0E0E0"]] forState:UIControlStateNormal];
    [self.btn1 setTitleColor:[UIColor colorWithHexString:@"#333333"] forState:UIControlStateNormal];

    [self.btn1 setBackgroundImage:[UIImage imageWithColor:[UIColor colorWithHexString:@"#F7941E"]] forState:UIControlStateSelected];
    [self.btn1 setTitleColor:[UIColor whiteColor] forState:UIControlStateSelected];

    
    [self.btn2 setBackgroundImage:[UIImage imageWithColor:[UIColor colorWithHexString:@"#E0E0E0"]] forState:UIControlStateNormal];
    [self.btn2 setTitleColor:[UIColor colorWithHexString:@"#333333"] forState:UIControlStateNormal];
    
    [self.btn2 setBackgroundImage:[UIImage imageWithColor:[UIColor colorWithHexString:@"#F7941E"]] forState:UIControlStateSelected];
    [self.btn2 setTitleColor:[UIColor whiteColor] forState:UIControlStateSelected];

    [self.btn3 setBackgroundImage:[UIImage imageWithColor:[UIColor colorWithHexString:@"#E0E0E0"]] forState:UIControlStateNormal];
    [self.btn3 setTitleColor:[UIColor colorWithHexString:@"#333333"] forState:UIControlStateNormal];
    
    [self.btn3 setBackgroundImage:[UIImage imageWithColor:[UIColor colorWithHexString:@"#F7941E"]] forState:UIControlStateSelected];
    [self.btn3 setTitleColor:[UIColor whiteColor] forState:UIControlStateSelected];
    
    [self selected:0];
}

- (void)resetAll
{
    [self.btn1 setSelected:NO];
    self.lab1.textColor = [UIColor colorWithHexString:@"#333333"];

    [self.btn2 setSelected:NO];
    self.lab2.textColor = [UIColor colorWithHexString:@"#333333"];

    [self.btn3 setSelected:NO];
    self.lab3.textColor = [UIColor colorWithHexString:@"#333333"];
}

- (void)selected:(NSInteger)index
{
    [self resetAll];
    if (index == 0) {
        [self.btn1 setSelected:YES];
        self.lab1.textColor = [UIColor colorWithHexString:@"#F7941E"];
    }else if (index == 1) {
        [self.btn2 setSelected:YES];
        self.lab2.textColor = [UIColor colorWithHexString:@"#F7941E"];
    }else if (index == 2) {
        [self.btn3 setSelected:YES];
        self.lab3.textColor = [UIColor colorWithHexString:@"#F7941E"];
    }

}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
